<style lang="less">
  @import './login.less';
</style>

<template>
  <div class="login">
    <div class="login-con">
      <Card icon="log-in" title="欢迎登录" :bordered="false">
        <div class="form-con">
          <login-form @on-success-valid="handleSubmit"></login-form>
          <p class="login-tip1">{{this.tips}}</p>
        </div>
      </Card>
    </div>
  </div>
</template>

<script>
import LoginForm from '_c/login-form'
import { mapActions } from 'vuex'
export default {
  data () {
    return {
      err: ''
    }
  },
  computed: {
    tips () {
      return this.err
    }
  },
  components: {
    LoginForm
  },
  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo'
    ]),
    handleSubmit ({ userName, password }) {
      this.handleLogin({ userName, password }).then(res => {
        console.log('[store][user模块][完毕]=============')
        console.log('[store][user模块][router]=============')
        this.$router.push({
          name: this.$config.homeName
        })
      }).catch(err => {
        console.log('[store][user模块][完毕][捕获异常]=============')
        console.log(err)
        this.err = err.data
      })
    }
  }
}
</script>

<style>
  .login-tip1{
    font-size: 10px;
    text-align: center;
    color: red;
  }

</style>
